package com.hdd.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.remoting.rmi.RmiProxyFactoryBean;
import service.TestService;

@Configuration
public class RMIService {

    @Autowired
    private Environment env;

    @Bean
    public RmiProxyFactoryBean testService(){
        RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
        rmiProxyFactoryBean.setRefreshStubOnConnectFailure( true );
        rmiProxyFactoryBean.setRefreshStubOnConnectFailure( false );
        rmiProxyFactoryBean.setServiceUrl( env.getProperty( "rmi.com.service.url" )+"testService" );
        rmiProxyFactoryBean.setServiceInterface( TestService.class );
        return  rmiProxyFactoryBean;
    }
}
